package com.jerkin.trace;

import java.util.UUID;

/**
 * @version V1.0
 * @ClassName: ThreadAtmoic
 * @Description:
 * @author: huhongzhi
 * @date: 2020/7/27 18:31
 */
public class ThreadAtmoic {

    private static final ThreadLocal<String> TRACE = new ThreadLocal<>();

    public static void putTrace() {
        TRACE.set(simpleUUID());
    }

    public static String getTrace() {
        String trace = TRACE.get();
        if (trace == null || trace.length() == 0) {
            putTrace();
        }
        return TRACE.get();
    }


    public static String simpleUUID() {
        return UUID.randomUUID().toString();
    }
}
